package com.bxl.chooser.bean;

/**
 * 为了简便，进行了报文共用，实际不该共用。主要是为了节省时间
 *
 * @author baixl
 * @date 2021/3/25
 */
public class ChooseResponseMsg {
    //选举属性
    private int term;
    private boolean isVote;
    //写消息的时候，如果不是同步的server，返回当前的logIndex进行消息同步
    private int logIndex;
   
    private String code;
    private  String desc; 
    
    private String leaderIP;
    private int port;
    
    private String messageId;
    private String msgContent;
    
    public static ChooseResponseMsg success = new ChooseResponseMsg("1000","成功");
    public static ChooseResponseMsg fail = new ChooseResponseMsg("2000","失败");
    //切换主机
    public static ChooseResponseMsg change = new ChooseResponseMsg("3000","失败");
    //稍后重试
    public static ChooseResponseMsg retry = new ChooseResponseMsg("4000","失败");


    public ChooseResponseMsg(int term, boolean isVote) {
        this.term = term;
        this.isVote = isVote;
    }

    public ChooseResponseMsg(int term, boolean isVote, int logIndex) {
        this.term = term;
        this.isVote = isVote;
        this.logIndex = logIndex;
    }

    public ChooseResponseMsg(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public ChooseResponseMsg(String code, String desc, String messageId, String msgContent) {
        this.code = code;
        this.desc = desc;
        this.messageId = messageId;
        this.msgContent = msgContent;
    }

    public ChooseResponseMsg() {
    }

    public int getTerm() {
        return term;
    }

    public void setTerm(int term) {
        this.term = term;
    }

    public boolean isVote() {
        return isVote;
    }

    public void setVote(boolean vote) {
        isVote = vote;
    }

    public int getLogIndex() {
        return logIndex;
    }

    public void setLogIndex(int logIndex) {
        this.logIndex = logIndex;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getLeaderIP() {
        return leaderIP;
    }

    public void setLeaderIP(String leaderIP) {
        this.leaderIP = leaderIP;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public String getMsgContent() {
        return msgContent;
    }

    public void setMsgContent(String msgContent) {
        this.msgContent = msgContent;
    }
}
